/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConsultaEleccion.java
 *
 * Created on 14/11/2010, 05:00:15 PM
 */

package zonasoft.Vistas.Funcionales;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import zonasoft.Conceptos.Usuario;
import zonasoft.Manejadores.ManejadorUsuario;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import org.jdesktop.swingx.decorator.Filter;
import org.jdesktop.swingx.decorator.FilterPipeline;
import org.jdesktop.swingx.decorator.PatternFilter;
import zonasoft.Manejadores.ManejadorBaseDatos;

/**
 *
 * @author JORGE
 */
public class ListarUsuarios extends javax.swing.JDialog {

    /** Creates new form ConsultaEleccion */
    public ListarUsuarios(java.awt.Frame parent) {
         super(parent,true);
        initComponents();
        pack();
        Rectangle parentBounds = parent.getBounds();
        Dimension size = getSize();
        // Center in the parent
        int x = Math.max(0, parentBounds.x + (parentBounds.width - size.width) / 2);
        int y = Math.max(0, parentBounds.y + (parentBounds.height - size.height) / 2);
        setLocation(new Point(x, y));

        panelHistorial.setVisible(false);

         List<TableColumn> columnas=  tablaUsuarios.getColumns();
       columnasTablaSimpa.addItem("..Sin filtro...");
        for (TableColumn tableColumn : columnas) {
            String col= tableColumn.getHeaderValue().toString();
            columnasTablaSimpa.addItem(col);
        }

    }
        
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXTaskPaneContainer1 = new org.jdesktop.swingx.JXTaskPaneContainer();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaUsuarios = new org.jdesktop.swingx.JXTable();
        totalSim = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        aceptar = new javax.swing.JButton();
        listar = new javax.swing.JButton();
        limpiar = new javax.swing.JButton();
        panelHistorial = new org.jdesktop.swingx.JXCollapsiblePane();
        tituloHistorial = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        historiaUserSeleccionado = new javax.swing.JList();
        jLabel6 = new javax.swing.JLabel();
        columnasTablaSimpa = new javax.swing.JComboBox();
        filtroText = new javax.swing.JTextField();
        errorLabel = new javax.swing.JLabel();
        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        jXTaskPaneContainer2 = new org.jdesktop.swingx.JXTaskPaneContainer();
        jLabel29 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        labeltotal = new javax.swing.JTextArea();

        setTitle("Listar Usuarios");
        setResizable(false);

        jLabel1.setFont(new java.awt.Font("Lucida Bright", 3, 18));
        jLabel1.setText("Listado de Usuarios");
        jXTaskPaneContainer1.add(jLabel1);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.gray, java.awt.Color.lightGray, java.awt.Color.darkGray, java.awt.Color.gray), "Usuarios", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Bright", 1, 12))); // NOI18N

        tablaUsuarios.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.blue, new java.awt.Color(51, 102, 255)));
        tablaUsuarios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Identificacion", " Nombre de Usuario","Fecha de Registro"
            }
        ));
        tablaUsuarios.setEditable(false);
        tablaUsuarios.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaUsuariosMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tablaUsuarios);

        totalSim.setEditable(false);

        jLabel2.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel2.setText("Actualmente hay:");

        jLabel3.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel3.setText("Usuarios Registrados");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(totalSim, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(totalSim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.black, java.awt.Color.black, java.awt.Color.lightGray, java.awt.Color.lightGray));

        aceptar.setFont(new java.awt.Font("Lucida Bright", 3, 12));
        aceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/ok 32.png"))); // NOI18N
        aceptar.setText("Aceptar");
        aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aceptarActionPerformed(evt);
            }
        });

        listar.setFont(new java.awt.Font("Lucida Bright", 3, 12));
        listar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/community-users-icon2.png"))); // NOI18N
        listar.setText("Listar");
        listar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listarActionPerformed(evt);
            }
        });

        limpiar.setFont(new java.awt.Font("Lucida Bright", 3, 12));
        limpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/limpiar.png"))); // NOI18N
        limpiar.setText("Limpiar");
        limpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(aceptar, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(limpiar, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                    .addComponent(listar, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(listar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addComponent(limpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(aceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        tituloHistorial.setFont(new java.awt.Font("Tahoma", 1, 12));
        tituloHistorial.setText("Historial del Usuario ");

        historiaUserSeleccionado.setFont(new java.awt.Font("Tahoma", 1, 11));
        jScrollPane2.setViewportView(historiaUserSeleccionado);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel6.setText("Filtrar Por");

        columnasTablaSimpa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                columnasTablaSimpaActionPerformed(evt);
            }
        });

        filtroText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                filtroTextKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                filtroTextKeyReleased(evt);
            }
        });

        errorLabel.setForeground(new java.awt.Color(255, 0, 0));
        errorLabel.setText("No  ha seleccionado ningun filtro...");

        jXPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, java.awt.Color.lightGray, java.awt.Color.lightGray, java.awt.Color.darkGray, java.awt.Color.darkGray));

        jLabel29.setBackground(new java.awt.Color(255, 255, 255));
        jLabel29.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel29.setText("    Auditoria VRM");
        jLabel29.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white));
        jXTaskPaneContainer2.add(jLabel29);

        jLabel4.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel4.setText("Total Registros");

        labeltotal.setColumns(20);
        labeltotal.setEditable(false);
        labeltotal.setFont(new java.awt.Font("Segoe Print", 1, 12)); // NOI18N
        labeltotal.setRows(5);
        jScrollPane3.setViewportView(labeltotal);

        javax.swing.GroupLayout jXPanel1Layout = new javax.swing.GroupLayout(jXPanel1);
        jXPanel1.setLayout(jXPanel1Layout);
        jXPanel1Layout.setHorizontalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE))
            .addComponent(jXTaskPaneContainer2, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel1Layout.createSequentialGroup()
                .addContainerGap(32, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(28, 28, 28))
        );
        jXPanel1Layout.setVerticalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel1Layout.createSequentialGroup()
                .addComponent(jXTaskPaneContainer2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, 740, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addComponent(columnasTablaSimpa, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(filtroText, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(errorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addComponent(tituloHistorial))
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(panelHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 538, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jXPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel6))
                    .addComponent(columnasTablaSimpa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(filtroText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(errorLabel)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(tituloHistorial)
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addComponent(panelHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jXPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane2))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void listarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listarActionPerformed
        // TODO add your handling code here:
             limpiarTabla();
            listaUsuario();
    }//GEN-LAST:event_listarActionPerformed

    private void aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptarActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_aceptarActionPerformed

    private void limpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limpiarActionPerformed
        // TODO add your handling code here:
        limpiarTabla();
        limpiarHistorial();
        labeltotal.setText("");
    }//GEN-LAST:event_limpiarActionPerformed

    private void tablaUsuariosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaUsuariosMouseClicked
        // TODO add your handling code here
        DefaultListModel listModel = new DefaultListModel();
        ManejadorBaseDatos mb = ManejadorBaseDatos.getInstancia();
         int indice=1;
        try {
            mb.conectar();
        } catch (Exception ex) {
            Logger.getLogger(ListarUsuarios.class.getName()).log(Level.SEVERE, null, ex);
        }

         ManejadorUsuario.conm =mb.getConexion();
         
           if(evt.getClickCount() == 1)
        {

          int fila =tablaUsuarios.rowAtPoint(evt.getPoint());
          int columna=tablaUsuarios.columnAtPoint(evt.getPoint());
         if ((fila > -1) && (columna > -1))
         {
             if(columna==0)
             {
                 int id=(Integer) tablaUsuarios.getValueAt(fila, columna);
                Usuario u=null;
                    try {
                        
                        u = ManejadorUsuario.getUsuario(String.valueOf(id));
                        List<String> h=u.getHistorial();
                        String header="           Fecha                                Hora Entrada               Hora Salida";
                        listModel.addElement(header);
                        for (String item : h) {
                            listModel.addElement(indice+item);
                            indice++;
                        }
                        tituloHistorial.setText("");
                        String tituloHistorialN="Historial del Usuario ";
                        tituloHistorialN+=u.getLogin_usuario();
                        tituloHistorial.setText(tituloHistorialN);

                         historiaUserSeleccionado.setModel(listModel);
                         panelHistorial.setVisible(true);

                          // aqui traigo el numero de zonificados que ha ingresado
                          try {                        
                       int n =   ManejadorUsuario.cantidadByUsuario(id);
                       int m = ManejadorUsuario.cantidadByUsuario2(id);
                       int s = n + m;
                        labeltotal.setText("-- Zonificados -- "+"\n"+String.valueOf(n) + "\n" + "-- Lideres --"+"\n"+String.valueOf(m) + "\n" + "-- Total --" + "\n"+s);
                               } catch (SQLException ex) {
                        Logger.getLogger(ListarUsuarios.class.getName()).log(Level.SEVERE, null, ex);
                    }
   // ------------------------------------------------------
                    } catch (SQLException ex) {
                        Logger.getLogger(ListarUsuarios.class.getName()).log(Level.SEVERE, null, ex);
                        ex.printStackTrace();
                    }
             }
             else
             {
             JOptionPane.showMessageDialog(null,"Por favor de click en el id del Usuario");
             }
         }

        }
    }//GEN-LAST:event_tablaUsuariosMouseClicked

    private void columnasTablaSimpaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_columnasTablaSimpaActionPerformed
        // TODO add your handling code here:
        hacerLosFiltros();
}//GEN-LAST:event_columnasTablaSimpaActionPerformed

    private void filtroTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_filtroTextKeyPressed
        // TODO add your handling code here:
        filtroTextKeyReleased(evt);
}//GEN-LAST:event_filtroTextKeyPressed

    private void filtroTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_filtroTextKeyReleased
        hacerLosFiltros();
}//GEN-LAST:event_filtroTextKeyReleased
private void hacerLosFiltros()
    {
        try {
            limpiarTabla();
            // TODO add your handling code here:
            String filtro=filtroText.getText();
            int columna=columnasTablaSimpa.getSelectedIndex();
            if(columna>0 && !filtro.isEmpty() && filtro!=null)
            { errorLabel.setVisible(false);
                columna-=1;
            //FilterPipeline filtros = new FilterPipeline(new Filter[] { new PatternFilter(filtro, 0, 0),new PatternFilter(filtro,1, 1) });
            PatternFilter p1 =new PatternFilter(filtro, -1, columna);
                Filter[] filterArray = {p1};
	        FilterPipeline filters = new FilterPipeline(filterArray);

            tablaUsuarios.setFilters(filters);
            }
            else
            {
            Filter[] filterArray = {};
	    FilterPipeline filters = new FilterPipeline(filterArray);
            tablaUsuarios.setFilters(filters);
            if(columna==0 )
            errorLabel.setVisible(true);
            if(filtro==null || filtro.isEmpty())
                errorLabel.setVisible(false);
            }

            listaUsuario();


        } catch (Exception ex) {
            Logger.getLogger(ListarUsuarios.class.getName()).log(Level.SEVERE, null, ex);
            ex.printStackTrace();
        }
    }
    public void listaUsuario(){
          Vector<Usuario> usu = null;
          try {
             usu = (Vector<Usuario>) ManejadorUsuario.listarUsuarios();
          Iterator i = usu.iterator();
            DefaultTableModel dtm = (DefaultTableModel)tablaUsuarios.getModel();
            Usuario us = new Usuario();
            while(i.hasNext()){
            us = (Usuario) i.next();
            String fecha = String.valueOf(us.getFecha_registro());
            Object []fila = {us.getId(),us.getLogin_usuario(),us.getFecha_registro()};
            if(!us.getLogin_usuario().endsWith("_"))
            dtm.addRow(fila);
             int r = dtm.getRowCount();
            
            }
            int t=tablaUsuarios.getFilters().getOutputSize();
            totalSim.setText(String.valueOf(t));
        } catch (Exception ex) {
            Logger.getLogger(ListarUsuarios.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
  public void limpiarTabla(){
          DefaultTableModel dtm = (DefaultTableModel)tablaUsuarios.getModel();
           dtm.setRowCount(0);
           totalSim.setText("");
    }
    public void limpiarHistorial(){
          DefaultListModel listm=new DefaultListModel();
          historiaUserSeleccionado.setModel(listm);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton aceptar;
    private javax.swing.JComboBox columnasTablaSimpa;
    private javax.swing.JLabel errorLabel;
    private javax.swing.JTextField filtroText;
    private javax.swing.JList historiaUserSeleccionado;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer1;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer2;
    private javax.swing.JTextArea labeltotal;
    private javax.swing.JButton limpiar;
    private javax.swing.JButton listar;
    private org.jdesktop.swingx.JXCollapsiblePane panelHistorial;
    private org.jdesktop.swingx.JXTable tablaUsuarios;
    private javax.swing.JLabel tituloHistorial;
    private javax.swing.JTextField totalSim;
    // End of variables declaration//GEN-END:variables

}
